using System.Collections;
using Examples;
using UnityEngine;
using cframework_coroutineutil;
using System.Linq;

public class ExampleWaitAll : ExampleBase
{
    private void Start()
    {
        StartCoroutine(ExampleCoroutine());
    }

    private IEnumerator ExampleCoroutine()
    {
        yield return StartCoroutine(WaitAllExampleOne());
        Debug.Log(string.Empty);
        //yield return StartCoroutine(WaitAllExampleTwo());
    }

    private IEnumerator WaitAllExampleOne()
    {
        Debug.Log("WaitAll example #1 started");
        var waitAll = new WaitAll(WaitOne(), WaitTwo(), WaitThree());
        yield return waitAll;
        Debug.Log("WaitAll example #1 ended " + string.Join(",", waitAll.results.ToList().ConvertAll(a => a.finished)));
    }
    
    //private IEnumerator WaitAllExampleTwo()
    //{
    //    Debug.Log("WaitAll example #2 started");
    //    yield return this.WaitAll(WaitOne(), WaitTwo(), WaitThree());
    //    Debug.Log("WaitAll example #2 started");
    //}
}

